﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel.DomainServices.Server;
using System.ServiceModel.DomainServices.Hosting;

namespace Imtihan.Web
{
    public partial class ImtihanDomainService
    {
        /// <summary>
        /// Get user assessment schedules by passing assessment schedule id.
        /// </summary>
        /// <param name="assessmentScheduleId">assessment schedule id.</param>
        /// <returns>List of user assessment schedule for specific assessment schedule.</returns>
        //[Invoke]
        public List<Answer> GetAnswerByProblemId(Guid problemId)
        {
            var answers = from entities in this.ObjectContext.ProblemAnswers.Include("Answer")
                          where entities.ProblemId == problemId
                          select entities.Answer;

            return answers.ToList();
        }

        public List<ProblemAnswer> GetProblemAnswerByProblemId(Guid problemId)
        {
            var problemAnsswers = from entities in this.ObjectContext.ProblemAnswers.Include("Answer").Include("Problem")
                                  where entities.ProblemId == problemId
                                  select new ProblemAnswer { Answer = entities.Answer, Problem = entities.Problem, Id = entities.Id, IsAnswer = entities.IsAnswer };

            return problemAnsswers.ToList();
        }
    }
}